#include <stdio.h>
#include <stdlib.h>

void nowexit1(void)
{
	printf("=== start nowexit1() ===\n");
	printf("This is out of main function\n");
	sleep(2);
	printf("=== end nowexit1() ===\n\n");
}

void nowexit2(void)
{
	printf("=== start nowexit2() ===\n");
	printf("This is out of main function\n");
	sleep(2);
	printf("=== end nowexit2() ===\n\n");
}

int main()
{
	// 최대 32개까지 함수를 등록할 수 있으며
	// 나중에 등록된 함수가 먼저 실행된다.
	atexit(nowexit1);
	atexit(nowexit2);

	printf("This is main function\n");
	printf("Press any key to exit\n");
	getchar();

	exit(0);
}
